package com.syuntax.util;

import com.greenpineyu.fel.FelEngine;
import com.greenpineyu.fel.FelEngineImpl;
import com.greenpineyu.fel.context.FelContext;
import com.syuntax.domain.IndexElement;
import com.syuntax.domain.IndexInfo;
import com.syuntax.domain.IndexType;
import com.syuntax.domain.IndexValue;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;

/**
 *
 * Created by Administrator on 2017/9/23.
 */
public class DataUtils {

    public static List<IndexInfo> indexInfoList = new ArrayList<>();
    public static List<IndexElement> indexElementList = new ArrayList<>();
    public static List<IndexType> indexTypeList = new ArrayList<>();
    public static List<IndexValue> indexValueList = new ArrayList<>();

    private static List<IndexInfo> include_indexInfoList = new ArrayList<>();



    /**
     * 输出list结果
     * */
    public static void printIndexValue(List<IndexValue> indexValueList){
        for(IndexValue indexValue : indexValueList){
            System.out.println(indexValue.toString());
        }
    }

    /**
     * 初始化数据
     * */
    public static void init(){
        // 初始化type表
        initType();
        // 初始化元素表
        initElement();
        // 初始化指标表
        initIndex();
    }

    /**
     * 根据主键查询类型
     * @param type_id 类型主键
     * */
    public static IndexType queryTypeById(long type_id){
        return indexTypeList.get(Integer.valueOf(String.valueOf(type_id-1)));
    }

    /**
     * 根据code查询元素
     * @param code 元素编码
     * */
    public static IndexElement queryElementByCode(String code){
        for(IndexElement indexElement : indexElementList){
            if(indexElement.getEle_code().equals(code)){
                return indexElement;
            }
        }
        return null;
    }

    /**
     * 根据id查询指标
     * @param index_id 主键
     * */
    public static IndexInfo queryIndexById(long index_id){
        for(IndexInfo indexInfo : indexInfoList){
            if(indexInfo.getIndex_id() == index_id){
                return indexInfo;
            }
        }
        return null;
    }

    /**
     * 根据code查询指标
     * @param code 指标编码
     * */
    public static IndexInfo queryIndexByCode(String code){
        for(IndexInfo indexInfo : indexInfoList){
            if(indexInfo.getIndex_code().equals(code)){
                return indexInfo;
            }
        }
        return null;
    }

    /**
     * 公式分解,解析公式包含的子公式
     * @param indexInfo 指标信息
     * */
    public static List<IndexInfo> formulaResolve(IndexInfo indexInfo){
        List<IndexInfo> include_indexInfoList_tmp = new ArrayList<>();
        String include_code = indexInfo.getInclude_code();
        if(include_code.contains(",")){
            String[] sub_codes = include_code.split(",");
            for(String sub_code : sub_codes){
                if(sub_code.contains("M")){
                    IndexInfo indexInfo1 = queryIndexByCode(sub_code);
                    include_indexInfoList.add(indexInfo1);
                    include_indexInfoList_tmp.add(indexInfo1);
                }
            }
        }else{
            if(include_code.contains("M")){
                IndexInfo indexInfo1 = queryIndexByCode(include_code);
                include_indexInfoList.add(indexInfo1);
                include_indexInfoList_tmp.add(indexInfo1);
            }
        }
        for(IndexInfo indexInfo1 : include_indexInfoList_tmp){
            formulaResolve(indexInfo1);
        }
        return include_indexInfoList;
    }

    /**
     * 指标计算
     * @param indexInfo 指标信息
     * */
    public static void indexCal(IndexInfo indexInfo){
        // 先清空缓存
        include_indexInfoList.clear();
        // 解析子指标
        List<IndexInfo> indexInfoList = formulaResolve(indexInfo);
        // 加上指标本身
        indexInfoList.add(indexInfo);
        // 将公式解析为要计算的结果信息
        formulaResolveValue(indexInfoList);
        // 对要计算的指标结果进行排序
        indexValueSortByLevel();

        for(IndexValue indexValue1 : indexValueList){
            calIndexVal(indexValue1);
        }
    }

    /**
     * 将公式解析为要计算的结果信息
     * @param indexInfoList 要计算的公式
     * */
    private static void formulaResolveValue(List<IndexInfo> indexInfoList) {
        String type = "FOR";
        IndexInfo index_type = null;
        for(IndexInfo indexInfo : indexInfoList){
            if(queryTypeById(indexInfo.getCal_type_id()).getType_code().equals("BDV")){
                type = "BDV";
                index_type = indexInfo;
            }
            if(queryTypeById(indexInfo.getCal_type_id()).getType_code().equals("1-12")){
                type = "1-12";
                index_type = indexInfo;
            }
            if(queryTypeById(indexInfo.getCal_type_id()).getType_code().equals("36912")){
                type = "36912";
                index_type=  indexInfo;
            }
        }

        // 普通公式计算，根据公式添加多少条结果
        if(type.equals("FOR")){
            for(IndexInfo indexInfo : indexInfoList){
                IndexValue indexValue = new IndexValue(1, indexInfo.getIndex_id(), 1, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                indexValueList.add(indexValue);
            }
        }
        // 如果包含变动率计算，则变动率所属的子公式追加基期的结果
        if(type.equals("BDV")){
            // 获取变动率公式等级
            long level = index_type.getIndex_level_id();
            // 比变动率等级低的公式追加基期结果
            for(IndexInfo indexInfo : indexInfoList){
                if(indexInfo.getIndex_level_id() < level){
                    IndexValue indexValue_bq = new IndexValue(1, indexInfo.getIndex_id(), 1, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_jq = new IndexValue(1, indexInfo.getIndex_id(), 0, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    indexValueList.add(indexValue_bq);
                    indexValueList.add(indexValue_jq);
                }else{
                    IndexValue indexValue = new IndexValue(1, indexInfo.getIndex_id(), 1, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    indexValueList.add(indexValue);
                }
            }
        }
        // 如果包含1-12月计算， 则子公式追加1-12月的结果
        if(type.equals("1-12")){
            // 获取变动率公式等级
            long level = index_type.getIndex_level_id();
            // 比变动率等级低和其本身的公式追加1-12月的结果
            for(IndexInfo indexInfo : indexInfoList){
                if(indexInfo.getIndex_level_id() <= level){
                    IndexValue indexValue_1 = new IndexValue(1, indexInfo.getIndex_id(), 1, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_2 = new IndexValue(2, indexInfo.getIndex_id(), 2, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_3 = new IndexValue(3, indexInfo.getIndex_id(), 3, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_4 = new IndexValue(4, indexInfo.getIndex_id(), 4, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_5 = new IndexValue(5, indexInfo.getIndex_id(), 5, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_6 = new IndexValue(6, indexInfo.getIndex_id(), 6, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_7 = new IndexValue(7, indexInfo.getIndex_id(), 7, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_8 = new IndexValue(8, indexInfo.getIndex_id(), 8, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_9 = new IndexValue(9, indexInfo.getIndex_id(), 9, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_10 = new IndexValue(10, indexInfo.getIndex_id(), 10, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_11 = new IndexValue(11, indexInfo.getIndex_id(), 11, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_12 = new IndexValue(12, indexInfo.getIndex_id(), 12, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    indexValueList.add(indexValue_1);
                    indexValueList.add(indexValue_2);
                    indexValueList.add(indexValue_3);
                    indexValueList.add(indexValue_4);
                    indexValueList.add(indexValue_5);
                    indexValueList.add(indexValue_6);
                    indexValueList.add(indexValue_7);
                    indexValueList.add(indexValue_8);
                    indexValueList.add(indexValue_9);
                    indexValueList.add(indexValue_10);
                    indexValueList.add(indexValue_11);
                    indexValueList.add(indexValue_12);
                }else{
                    IndexValue indexValue = new IndexValue(1, indexInfo.getIndex_id(), 1, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    indexValueList.add(indexValue);
                }
            }
        }
        // 如果计算3,6,9,12，则追加3,6,9,12
        if(type.equals("36912")){
            // 等级
            long level = index_type.getIndex_level_id();
            // 比指标等级低和其本身的公式追加3,6,9,12月的结果
            for(IndexInfo indexInfo : indexInfoList){
                if(indexInfo.getIndex_level_id() <= level){
                    IndexValue indexValue_3 = new IndexValue(3, indexInfo.getIndex_id(), 3, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_6 = new IndexValue(6, indexInfo.getIndex_id(), 6, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_9 = new IndexValue(9, indexInfo.getIndex_id(), 9, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    IndexValue indexValue_12 = new IndexValue(12, indexInfo.getIndex_id(), 12, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    indexValueList.add(indexValue_3);
                    indexValueList.add(indexValue_6);
                    indexValueList.add(indexValue_9);
                    indexValueList.add(indexValue_12);
                }else{
                    IndexValue indexValue = new IndexValue(1, indexInfo.getIndex_id(), 1, new BigDecimal(0), new Timestamp(System.currentTimeMillis()));
                    indexValueList.add(indexValue);
                }
            }
        }
    }

    /**
     * 计算某个指标的结果
     * @param indexValue 要计算的指标结果
     * */
    public static void calIndexVal(IndexValue indexValue){
        // 获取指标等级
        String level = queryTypeById(queryIndexById(indexValue.getIndex_id()).getIndex_level_id()).getType_code();
        switch (level){
            case "1":
                String include_code = queryIndexById(indexValue.getIndex_id()).getInclude_code();
                if(include_code.contains(",")){
                    String[] include_codes = include_code.split(",");
                    FelEngine fel = new FelEngineImpl();
                    // 普通公式计算
                    if(queryTypeById(queryIndexById(indexValue.getIndex_id()).getCal_type_id()).getType_code().equals("FOR")){
                        FelContext ctx = fel.getContext();
                        for(String code : include_codes){
                            BigDecimal value = getElementValue(code);
                            ctx.set(code, value);
                            //System.out.println(code + " = " + value);
                        }
                        Object result = fel.eval(queryIndexById(indexValue.getIndex_id()).getCal_code());
                        BigDecimal value = new BigDecimal(result.toString());
                        System.out.println("[" + queryIndexById(indexValue.getIndex_id()).getIndex_name() + indexValue.getDate_info_id() + "]" + queryIndexById(indexValue.getIndex_id()).getIndex_code() + " = " + queryIndexById(indexValue.getIndex_id()).getCal_code() + " = " + value);
                        indexValue.setValue(value);
                    }
                }else{
                    /*BigDecimal value = getElementValue(include_code);
                    System.out.println("[" + queryIndexById(indexValue.getIndex_id()).getIndex_name() + indexValue.getDate_info_id() + "]" + queryIndexById(indexValue.getIndex_id()).getIndex_code() + " = " + queryIndexById(indexValue.getIndex_id()).getCal_code() + " = " + value);
                    indexValue.setValue(value);*/
                }
                break;
            case "2":
                String include_code1 = queryIndexById(indexValue.getIndex_id()).getInclude_code();
                if(include_code1.contains(",")){
                    if(queryTypeById(queryIndexById(indexValue.getIndex_id()).getCal_type_id()).getType_code().equals("1-12")){
                        FelEngine fel = new FelEngineImpl();
                        String[] include_codes = include_code1.split(",");
                        FelContext ctx = fel.getContext();
                        for(String code : include_codes){
                            if(code.contains("E")){
                                BigDecimal value = getElementValue(code);
                                ctx.set(code, value);
                            }else{
                                BigDecimal value = queryValueByCon(queryIndexByCode(code).getIndex_id(), indexValue.getDate_info_id()).getValue();
                                ctx.set(code, value);
                            }
                            //System.out.println(code + " = " + value);
                        }
                        Object result = fel.eval(queryIndexById(indexValue.getIndex_id()).getCal_code());
                        BigDecimal value = new BigDecimal(result.toString());
                        System.out.println("[" + queryIndexById(indexValue.getIndex_id()).getIndex_name() + indexValue.getDate_info_id() + "]" + queryIndexById(indexValue.getIndex_id()).getIndex_code() + " = " + queryIndexById(indexValue.getIndex_id()).getCal_code() + " = " + value);
                        indexValue.setValue(value);
                    }
                    if(queryTypeById(queryIndexById(indexValue.getIndex_id()).getCal_type_id()).getType_code().equals("36912")){
                        FelEngine fel = new FelEngineImpl();
                        String[] include_codes = include_code1.split(",");
                        FelContext ctx = fel.getContext();
                        for(String code : include_codes){
                            if(code.contains("E")){
                                BigDecimal value = getElementValue(code);
                                ctx.set(code, value);
                            }else{
                                BigDecimal value = queryValueByCon(queryIndexByCode(code).getIndex_id(), indexValue.getDate_info_id()).getValue();
                                ctx.set(code, value);
                            }
                            //System.out.println(code + " = " + value);
                        }
                        Object result = fel.eval(queryIndexById(indexValue.getIndex_id()).getCal_code());
                        BigDecimal value = new BigDecimal(result.toString());
                        System.out.println("[" + queryIndexById(indexValue.getIndex_id()).getIndex_name() + indexValue.getDate_info_id() + "]" + queryIndexById(indexValue.getIndex_id()).getIndex_code() + " = " + queryIndexById(indexValue.getIndex_id()).getCal_code() + " = " + value);
                        indexValue.setValue(value);
                    }
                }else{
                    FelEngine fel = new FelEngineImpl();
                    // 变动率计算
                    if(queryTypeById(queryIndexById(indexValue.getIndex_id()).getCal_type_id()).getType_code().equals("BDV")){
                        IndexInfo indexInfo1 = queryIndexByCode(include_code1);
                        // 获取本期的值，这里临时给个随机值
                        BigDecimal bq = queryValueByCon(indexInfo1.getIndex_id(), 1).getValue();
                        // 获取上期的值
                        BigDecimal jq = queryValueByCon(indexInfo1.getIndex_id(), 0).getValue();
                        String formula = "(bq-jq)/jq";
                        FelContext ctx = fel.getContext();
                        ctx.set("bq", bq);
                        ctx.set("jq", jq);
                        Object result = fel.eval(formula);
                        BigDecimal value = new BigDecimal(result.toString());
                        System.out.println("[" + queryIndexById(indexValue.getIndex_id()).getIndex_name() + indexValue.getDate_info_id() + "]" + queryIndexById(indexValue.getIndex_id()).getIndex_code() + " = (bq-jq)/jq = " + value);
                        indexValue.setValue(value);
                        //indexValueList_result.add(indexValue);
                    }

                }
                break;
            case "3":
                String include_code3 = queryIndexById(indexValue.getIndex_id()).getInclude_code();
                if(include_code3.contains(",")){
                    String[] include_codes = include_code3.split(",");
                    FelEngine fel = new FelEngineImpl();
                    // 普通公式计算
                    if(queryTypeById(queryIndexById(indexValue.getIndex_id()).getCal_type_id()).getType_code().equals("FOR")){
                        FelContext ctx = fel.getContext();
                        for(String code : include_codes){
                            BigDecimal value = queryValueByCon(queryIndexByCode(code).getIndex_id(), 1).getValue();
                            ctx.set(code, value);
                            System.out.println(code + " = " + value);
                        }
                        Object result = fel.eval(queryIndexById(indexValue.getIndex_id()).getCal_code());
                        BigDecimal value = new BigDecimal(result.toString());
                        System.out.println("[" + queryIndexById(indexValue.getIndex_id()).getIndex_name() + indexValue.getDate_info_id() + "]" + queryIndexById(indexValue.getIndex_id()).getIndex_code() + " = " + queryIndexById(indexValue.getIndex_id()).getCal_code() + " = " + value);
                        indexValue.setValue(value);
                    }
                }else{

                }
                break;
            case "4":
                break;
            default:
                break;
        }

    }

    /**
     * 通过指标主键和日期获取值
     * @param index_id 指标主键
     * @param date_info_id 日期类型主键
     * */
    private static IndexValue queryValueByCon(long index_id, long date_info_id) {
        for(IndexValue indexValue : indexValueList){
            if(indexValue.getIndex_id() == index_id && indexValue.getDate_info_id() == date_info_id){
                return indexValue;
            }
        }
        return null;
    }

    /**
     * 指标按照等级排序,从低到高
     * @param indexInfoList 要排序的指标集合
     * */
    public static List<IndexInfo> indexSortByLevel(List<IndexInfo> indexInfoList){
        Collections.sort(indexInfoList, new Comparator<IndexInfo>() {
            @Override
            public int compare(IndexInfo o1, IndexInfo o2) {
                return o1.compareTo(o2);
            }
        });
        return indexInfoList;
    }

    /**
     * 指标结果按照等级排序,从低到高
     * */
    public static void indexValueSortByLevel(){
        Collections.sort(indexValueList, new Comparator<IndexValue>() {
            @Override
            public int compare(IndexValue o1, IndexValue o2) {
                return o1.compareTo(o2);
            }
        });

    }

    /**
     * 从指标元素里获取对应的指标元素值
     * */
    public static BigDecimal getElementValue(String code){
        IndexElement indexElement = queryElementByCode(code);
        int max=20;
        int min=1;
        Random random = new Random();

        int s = random.nextInt(max)%(max-min+1) + min;
        return new BigDecimal(s);
    }

    public static void main(String[] args){
        init();
        IndexInfo indexInfo = queryIndexByCode("M007");
        indexCal(indexInfo);
        printIndexValue(indexValueList);
    }

    /**
     * 初始化指标表
     * */
    public static void initIndex() {
        IndexInfo indexInfo1 = new IndexInfo(1L, "营业收入变动率", "M001", "M002", "M002", 23L, 11L, 1L, 1L);
        IndexInfo indexInfo2 = new IndexInfo(2L, "营业收入", "M002", "E001+E002", "E001,E002",22L, 10L, 1L, 1L);
        IndexInfo indexInfo3 = new IndexInfo(3L, "营业收入变动率与营业成本变动率弹性系数", "M003", "M001/M005", "M001,M005",22L, 12L, 1L, 1L);
        IndexInfo indexInfo4 = new IndexInfo(4L, "营业成本", "M004", "E003+E004", "E003,E004",22L, 10L, 1L, 1L);
        IndexInfo indexInfo5 = new IndexInfo(5L, "营业成本变动率", "M005", "M004", "M004", 23L, 11L, 1L, 1L);
        IndexInfo indexInfo6 = new IndexInfo(6L, "预收账款占主营业务收入比", "M006", "E005/M002", "E005,M002", 25L, 11L, 1L, 1L);
        IndexInfo indexInfo7 = new IndexInfo(7L, "预缴企业所得税评估", "M007", "E006/M008/4", "E005,M002", 26L, 11L, 1L, 1L);
        IndexInfo indexInfo8 = new IndexInfo(8L, "利润总额", "M008", "E001+E002+E007+E008+E009-E003-E004-E010-E011-E012-E013-E014", "E001,E002,E007,E008,E009,E003,E004,E010,E011,E012,E013,E014", 22L, 10L, 1L, 1L);
        //主营业务收入6001+其他业务收入6051+公允价值变动损益6101+投资收益6111+营业外收入6301
        //-（主营业务成本6401+其他业务成本+6402+营业税金及附加6403+销售费用6601+管理费用6602+财务费用6603+营业外支出6711）

        // E001+E002+E007+E008+E009-E003-E004-E010-E011-E012-E013-E014

        indexInfoList.add(indexInfo1);
        indexInfoList.add(indexInfo2);
        indexInfoList.add(indexInfo3);
        indexInfoList.add(indexInfo4);
        indexInfoList.add(indexInfo5);
        indexInfoList.add(indexInfo6);
        indexInfoList.add(indexInfo7);
        indexInfoList.add(indexInfo8);
    }

    /**
     * 初始化元素表
     * */
    public static void initElement() {
        IndexElement indexElement1 = new IndexElement(1, "主营业务收入", "E001", "6001", 1L, 1L);
        IndexElement indexElement2 = new IndexElement(2, "其他业务收入", "E002", "6051", 1L, 1L);
        IndexElement indexElement3 = new IndexElement(3, "主营业务成本", "E003", "6401", 1L, 1L);
        IndexElement indexElement4 = new IndexElement(4, "其他业务成本", "E004", "6402", 1L, 1L);
        IndexElement indexElement5 = new IndexElement(5, "预收账款", "E005", "2205", 1L, 1L);
        IndexElement indexElement6 = new IndexElement(6, "应交税费-应交所得税", "E006", "222105", 1L, 1L);
        IndexElement indexElement7 = new IndexElement(7, "公允价值变动损益", "E007", "6101", 1L, 1L);
        IndexElement indexElement8 = new IndexElement(8, "投资收益", "E008", "6111", 1L, 1L);
        IndexElement indexElement9 = new IndexElement(9, "营业外收入", "E009", "6301", 1L, 1L);
        IndexElement indexElement10 = new IndexElement(10, "营业税金及附加", "E010", "6403", 1L, 1L);
        IndexElement indexElement11 = new IndexElement(11, "销售费用", "E011", "6601", 1L, 1L);
        IndexElement indexElement12 = new IndexElement(12, "管理费用", "E012", "6602", 1L, 1L);
        IndexElement indexElement13 = new IndexElement(13, "财务费用", "E013", "6603", 1L, 1L);
        IndexElement indexElement14 = new IndexElement(14, "营业外支出", "E014", "6711", 1L, 1L);
        indexElementList.add(indexElement1);
        indexElementList.add(indexElement2);
        indexElementList.add(indexElement3);
        indexElementList.add(indexElement4);
        indexElementList.add(indexElement5);
        indexElementList.add(indexElement6);
        indexElementList.add(indexElement7);
        indexElementList.add(indexElement8);
        indexElementList.add(indexElement9);
        indexElementList.add(indexElement10);
        indexElementList.add(indexElement11);
        indexElementList.add(indexElement12);
        indexElementList.add(indexElement13);
        indexElementList.add(indexElement14);
    }

    /**
     * 初始化type表
     * */
    public static void initType() {
        IndexType indexType1 = new IndexType(1, "混合元素", "M", 1, "指标类型");
        IndexType indexType2 = new IndexType(2, "基础指标", "B", 1, "指标类型");
        IndexType indexType3 = new IndexType(3, "混合指标", "F", 1, "指标类型");
        IndexType indexType4 = new IndexType(4, "收入类项目", "F", 2, "所属类别");
        IndexType indexType5 = new IndexType(5, "扣除类项目", "F", 2, "所属类别");
        IndexType indexType6 = new IndexType(6, "资产类项目", "F", 2, "所属类别");
        IndexType indexType7 = new IndexType(7, "综合类项目", "F", 2, "所属类别");
        IndexType indexType8 = new IndexType(8, "特殊项目", "F", 2, "所属类别");
        IndexType indexType9 = new IndexType(9, "复杂项目", "F", 2, "所属类别");
        IndexType indexType10 = new IndexType(10, "等级1", "1", 2, "指标等级");
        IndexType indexType11 = new IndexType(11, "等级2", "2", 2, "指标等级");
        IndexType indexType12 = new IndexType(12, "等级3", "3", 2, "指标等级");
        IndexType indexType13 = new IndexType(13, "等级4", "4", 2, "指标等级");
        IndexType indexType14 = new IndexType(14, "月", "F", 2, "执行周期");
        IndexType indexType15 = new IndexType(15, "季", "F", 2, "执行周期");
        IndexType indexType16 = new IndexType(16, "年", "F", 2, "执行周期");
        IndexType indexType17 = new IndexType(17, "借方", "F", 2, "借贷方向");
        IndexType indexType18 = new IndexType(18, "贷方", "F", 2, "借贷方向");
        IndexType indexType19 = new IndexType(19, "累计发生额", "F", 2, "金额类型");
        IndexType indexType20 = new IndexType(20, "期初余额", "F", 2, "金额类型");
        IndexType indexType21 = new IndexType(21, "期末余额", "F", 2, "金额类型");
        IndexType indexType22 = new IndexType(22, "普通公式计算", "FOR", 2, "公式计算方式");
        IndexType indexType23 = new IndexType(23, "变动率计算", "BDV", 2, "公式计算方式");
        IndexType indexType24 = new IndexType(24, "平均值计算", "AVG", 2, "公式计算方式");
        IndexType indexType25 = new IndexType(25, "1-12月计算", "1-12", 2, "公式计算方式");
        IndexType indexType26 = new IndexType(26, "3,6,9,12月计算", "36912", 2, "公式计算方式");

        indexTypeList.add(indexType1);
        indexTypeList.add(indexType2);
        indexTypeList.add(indexType3);
        indexTypeList.add(indexType4);
        indexTypeList.add(indexType5);
        indexTypeList.add(indexType6);
        indexTypeList.add(indexType7);
        indexTypeList.add(indexType8);
        indexTypeList.add(indexType9);
        indexTypeList.add(indexType10);
        indexTypeList.add(indexType11);
        indexTypeList.add(indexType12);
        indexTypeList.add(indexType13);
        indexTypeList.add(indexType14);
        indexTypeList.add(indexType15);
        indexTypeList.add(indexType16);
        indexTypeList.add(indexType17);
        indexTypeList.add(indexType18);
        indexTypeList.add(indexType19);
        indexTypeList.add(indexType20);
        indexTypeList.add(indexType21);
        indexTypeList.add(indexType22);
        indexTypeList.add(indexType23);
        indexTypeList.add(indexType24);
        indexTypeList.add(indexType25);
        indexTypeList.add(indexType26);

    }

}
